from collections import defaultdict, deque, Counter
from itertools import permutations

nums = tuple(map(int, input().split()))


def check(n):
    # 判断n能不能分成3个数 使得 p + q + r = n 且操作使得两个为0
    # 记 p <= q <= r
    a, b, c = nums
    for p in range(0, n + 1):
        for q in range(p, n + 1):
            r = n - p - q
            if r < 0: break
            change1 = p + q - r
            change2 = p + r - q
            change3 = r + q - p
            for alphaPer in permutations([a, b, c]):
                a_, b_, c_ = alphaPer
                if Counter([a_ + change1, b_ + change2, c_ + change3])[0] >= 2:
                    return True
    return False


lo = 0
hi = sum(nums)
while lo <= hi:
    mid = (lo + hi) >> 1
    if check(mid):
        hi = mid - 1
    else:
        lo = mid + 1
print(hi + 1)

# bfs
min_distance = defaultdict(int)
visited = set()
queue = deque()
queue.append(nums)
while queue:
    curr = queue.popleft()
    if curr in visited:
        continue
    cx, cy, cz = curr
    cnt = Counter([cx, cy, cz])
    if cnt[0] >= 2:
        print(min_distance[curr])
        break
    for nx, ny, nz in [(-1, -1, 1), (-1, 1, -1), (1, -1, -1)]:
        next_node = (cx + nx, cy + ny, cz + nz)
        if next_node in visited: continue
        min_distance[next_node] = min_distance[curr] + 1
        queue.append(next_node)
